{template "header.html"}


<div class="page-content">

    <div class="container margin-top-30">


        <div class="row">

            <div class="col-md-9">
                <div class="row">
                    <div class="col-md-3">

                        <div class="book_left">
                            <img src="{dr_thumb($thumb, 150, 220)}">
                            <div class="{if $zt}zt1{else}zt0{/if}"></div>
                        </div>

                        <div class="book_sns">


                        </div>

                    </div>
                    <div class="col-md-9">
                        <div class="bookname">{$title} <small>{$biming}</small></div>
                        <div class="bookinfo">
                            分类：{$cat.name} <i>|</i>
                            收藏：{intval($favorites)} <i>|</i>
                            评论：{$comments} <i>|</i>
                            更新：{$updatetime} <i>|</i>
                            人气：{dr_show_hits($id)}
                        </div>
                        <div class="bookdesc">
                            {$description}
                        </div>
                        <p>

                        </p>
                    </div>
                </div>
                <div class="row">
                    <div class="portlet light" style="margin-bottom: 0">
                        <a href="{dr_url('api/buy/index', ['fid' => $ci->module['field']['price']['id'], 'id' => $id, 'num' => 1])}">pay</a>
                    </div>
                </div>

                <div class="form-body">
                    <div class="form-group row">
                        <label class="col-md-2 control-label fc-sku-group-html">商品价格</label>
                        <div class="col-md-10">
                            {if $duojiage_sku}
                            ￥<span id="dr_sku_price">{dr_sku_price($duojiage_sku, 2, ' ~ ')}</span>元
                            {else}
                            ￥<span>{number_format($duojiage, 2)}</span>元
                            {/if}
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-md-2 control-label fc-sku-group-html">商品编号</label>
                        <div class="col-md-10">
                            <span id="dr_sku_sn"> {$duojiage_sn} </span>
                        </div>
                    </div>
                    {if $duojiage_sku}
                    <div class="note note-info">

                        {loop $duojiage_sku['group'] $gid $gname}
                        <div class="form-group row">
                            <label class="col-md-2 control-label fc-sku-group-html">{$gname}</label>
                            <div class="col-md-10 fc-sku-select-price">
                                {php $i=0;}
                                {loop $duojiage_sku['name'][$gid] $vid $vname}
                                <button type="button" fvalue="{$gid}_{$vid}" class="fc-sku-value btn {if $i==0}red{/if} btn-default btn-xs">{$vname}</button>
                                {php $i=1;}
                                {/loop}
                            </div>
                        </div>
                        {/loop}
                        <input type="hidden" id="dr_sku_value" value="">
                        {loop $duojiage_sku['value'] $i $v}
                        <input type="hidden" id="dr_sku_sn_{$i}" value="{$v.sn}">
                        <input type="hidden" id="dr_sku_price_{$i}" value="{number_format($v.price,2)}">
                        <input type="hidden" id="dr_sku_quantity_{$i}" value="{$v.quantity}">
                        {/loop}
                    </div>

                    {/if}

                    <div class="form-group row">
                        <label class="col-md-2 control-label fc-sku-group-html">商品库存</label>
                        <div class="col-md-10">
                            <span id="dr_sku_quantity"> {$duojiage_quantity} </span>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-md-2 control-label fc-sku-group-html" style="margin-top:7px;">商品购买</label>
                        <div class="col-md-2">
                            <input id="dr_buy_num" type="text" value="1">
                        </div>
                        <a href="javascript:add_buy();" class="btn green"> <i class="fa fa-rmb"></i> 立即购买 </a>
                    </div>


                    <link href="{THEME_PATH}assets/global/plugins/bootstrap-touchspin/bootstrap.touchspin.css" rel="stylesheet" type="text/css" />
                    <script src="{THEME_PATH}assets/global/plugins/fuelux/js/spinner.min.js" type="text/javascript"></script>
                    <script src="{THEME_PATH}assets/global/plugins/bootstrap-touchspin/bootstrap.touchspin.js" type="text/javascript"></script>

                    <script type="text/javascript" src="{THEME_PATH}assets/js/sku.js"></script>
                    <script type="text/javascript">
                        $(function () {
                            dr_select_sku_price();
                            dr_get_sku_price();
                            $("#dr_buy_num").TouchSpin({
                                verticalbuttons: true,
                                step: 1,
                                min: 1,
                                max: $('#dr_sku_quantity').html()
                            });
                        })
                        // 购买地址
                        function add_buy() {
                            var url = "{dr_url('api/buy/index', ['fid' => $ci->module['field']['duojiage']['id'], 'id'=>$id])}";
                            url+= "&sku="+$('#dr_sku_value').val();
                            url+= "&num="+$('#dr_buy_num').val();
                            window.location.href = url;
                        }
                    </script>

                    {if $member.uid}
                    {if dr_is_buy($ci->module['field']['price']['id'], $id, $member.uid)}
                    已购买
                    {else}
                    未购买
                    {/if}
                    {else}
                    没有登录
                    {/if}
                </div>


            </div>




        </div>

    </div>

</div>
